/*******************************************************************************
 * Copyright (c) Jerges A. Bello G. 2014. Reservado todos los derechos.
 ******************************************************************************/
package com.jabex.persistence.model;

import com.jabex.common.to.SecurityTO;
import org.joda.time.LocalTime;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;

/**
 * Created by Jerges Bello on 15/05/2014.
 */
@Entity
@Table(name = "ADA_SECURITY")
public class Security extends Identity {
	@Column(name = "CREATE_DATE", unique = false, nullable = false)
	private Date createDate;
	@Column(name = "PASSWORD", unique = false, nullable = false)
	private String password;
	@Column(name = "NAME_APP", length = 20, unique = false, nullable = true)
	private String nameApp;
	@Column(name = "CODE_APP", length = 8, unique = false, nullable = false)
	private String codeApp;

	public Security() {
	}

	public Security(SecurityTO securityTO) {
		this.createDate = securityTO.getCreateDate().toDate();
		if (securityTO.getCreateTime() != null) {
			this.createDate.setTime(securityTO.getCreateTime().toDateTime().getMillis());
		} else {
			this.createDate.setTime(securityTO.getCreateDate().toDateTime(LocalTime.now()).getMillis());
		}
		this.password = securityTO.getPassword();
		this.nameApp = securityTO.getNameApp();
		this.codeApp = securityTO.getCodeApp();
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}


	public String getNameApp() {
		return nameApp;
	}

	public void setNameApp(String nameApp) {
		this.nameApp = nameApp;
	}


	public String getCodeApp() {
		return codeApp;
	}

	public void setCodeApp(String codeApp) {
		this.codeApp = codeApp;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
}
